package com.library.verification.manager;

import android.content.Context;
import android.view.View;

import com.library.verification.view.IBaseView;
import com.library.verification.window.IWindow;

/**
 * Created by zhoulikai on 17/4/18.
 * 抽象window管理
 */

public abstract class AbstractWindowManager {
    private IWindow window;
    private IBaseView view;

    public AbstractWindowManager(Context context, IWindowParameter parameter) {
        window = makeWindowObj(context, parameter);

        view = makeWindowView(context, parameter);
        if (view != null && window != null) {
            window.windowCreate(view.generateView());
        }

    }

    protected IBaseView getBaseView() {
        return view;
    }

    protected abstract IWindow makeWindowObj(Context context, IWindowParameter parameter);

    protected abstract IBaseView makeWindowView(Context context, IWindowParameter parameter);


    protected void show(View view) {
        if (window != null) {
            window.windowShow(view);
        }
    }


    public void dismiss() {
        if (window != null) {
            window.windowDismiss();
        }
    }
}
